package o;

import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.hms.framework.network.grs.GrsApi;
import com.huawei.hms.framework.network.restclient.dnkeeper.DNKeeperConfig;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

public class cng {
    private static String ˎ;
    private static cng ˏ;
    private static final Map<String, String> ॱ = new ConcurrentHashMap();

    private cng() {
    }

    static synchronized cng ˋ() {
        cng o_cng;
        synchronized (cng.class) {
            if (ˏ == null) {
                ˏ = new cng();
                ˎ();
            }
            o_cng = ˏ;
        }
        return o_cng;
    }

    public static void ॱ() {
        ॱ.clear();
        ˏ = null;
    }

    static void ˋ(String str) {
        if (str.equals("com.huawei.appmarket")) {
            ˎ = "com.huawei.appmarketV05";
        } else if (str.equals(PackageUtils.HWGAMEBOX_PACKAGE_NAME)) {
            ˎ = "com.huawei.gameboxV01";
        } else {
            ˎ = "com.huawei.appmarketV05";
        }
    }

    public static String ˊ() {
        return ˎ;
    }

    synchronized void ˊ(cne o_cne) {
        String ˊ = o_cne.ˊ();
        for (Entry entry : ॱ.entrySet()) {
            if (((String) entry.getKey()).equals(ˊ)) {
                o_cne.ˋ(cnr.ˊ(((String) entry.getValue()).trim()));
                break;
            }
        }
    }

    private static void ˎ() {
        Map synGetGrsUrls = GrsApi.synGetGrsUrls(ˎ);
        if (synGetGrsUrls != null) {
            for (Entry entry : synGetGrsUrls.entrySet()) {
                ॱ.put(ˎ + ":" + ((String) entry.getKey()), entry.getValue());
            }
        }
        synGetGrsUrls = GrsApi.synGetGrsUrls("com.huawei.cloud.hianalytics.aspg");
        if (synGetGrsUrls != null) {
            for (Entry entry2 : synGetGrsUrls.entrySet()) {
                ॱ.put("com.huawei.cloud.hianalytics.aspg:" + ((String) entry2.getKey()), entry2.getValue());
            }
        }
        synGetGrsUrls = GrsApi.synGetGrsUrls(DNKeeperConfig.SERVICE_NAME_BACKUP);
        if (synGetGrsUrls != null) {
            for (Entry entry22 : synGetGrsUrls.entrySet()) {
                ॱ.put("com.huawei.dnkeeper:" + ((String) entry22.getKey()), entry22.getValue());
            }
        }
        synGetGrsUrls = GrsApi.synGetGrsUrls("com.huawei.cloud.hwid");
        if (synGetGrsUrls != null) {
            for (Entry entry222 : synGetGrsUrls.entrySet()) {
                ॱ.put("com.huawei.cloud.hwid:" + ((String) entry222.getKey()), entry222.getValue());
            }
        }
    }
}
